cd %~dp0
%~d0


set /p changesavepath=<savepath.txt
set changesavepath=%changesavepath:\=/%
echo|set /p="%changesavepath%">savepath.txt

set "subslash=\"
set /p savepath= <savepath.txt

rem trim any slashes off the end
for /l %%a in (1,1,1) do if "!savepath:~-1!"=="/" set savepath=!savepath:~0,-1!
rem change to tomorrow path
set "tomsavepath=%savepath%tomorrow"
rem add slash to the end
set "savepath=%savepath%/"
rem change all slashes to windows
set savepath=%savepath:/=\%
rem add slash to the end
set "tomsavepath=%tomsavepath%/"
rem change all slashes to windows
set tomsavepath=%tomsavepath:/=\%

set noquotessavepath=%savepath%
for /f "useback tokens=*" %%a in ('%noquotessavepath%') do set noquotessavepath=%%~a

set noslashpath=%savepath%
for /l %%a in (1,1,31) do if "!noslashpath:~-1!"=="\" set noslashpath=!noslashpath:~0,-1!

rem forfiles -p ^"%noslashpath%^" -s -m *.pdf /D -4 /C "cmd /c del @PATH"
rem echo %noslashpath%

rem how many pdf files in directory?
set /a count=0
set "searchfilter=%savepath%*.pdf"
set searchfilter=^"%searchfilter%^"
for %%f in (%searchfilter%) do (set /a count=count+1
rem echo %%~nf
)
rem @echo on
for /f "tokens=*" %%a in ('dir "pdfs\*.pdf" /O:D /s /b') do (
	set currnewest=%%a
)
for /f "tokens=*" %%a in ('dir "pdfstomorrow\*.pdf" /O:D /s /b') do (
	set tomnewest=%%a
)

set "copyto=%savepath%tomorrowspdfnormalised.pdf"
copy /Y "%tomnewest%" "%copyto%"


